package com.pirestupppai.widgets.view;

import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.pirestupppai.R;
import com.pirestupppai.bean.FeedItem;
import com.pirestupppai.common.Constant;
import com.pirestupppai.ui.activity.DetailActivity;
import com.pirestupppai.utils.ImageLoadUtil;

/**
 * 标签页头部求P
 *
 * @author: xiaoluo
 * @date: 2017-04-26 15:11
 */
public class TagDetailAskView extends LinearLayout {
    private Context mContext;

    private ImageView mAskImage;
    private TextView mAskTv;

    private FeedItem mFeedItem;

    public TagDetailAskView(Context context, FeedItem item) {
        super(context,null);
        this.mFeedItem = item;
        this.mContext = context;
        LayoutInflater.from(mContext).inflate(R.layout.widget_tag_ask, this, true);

        mAskImage = (ImageView) this.findViewById(R.id.ask_image);
        mAskTv = (TextView) this.findViewById(R.id.ask_tv);

        mAskTv.setText(item.getDesc());
        if (item.getMedias() != null && item.getMedias().size() != 0) {
            ImageLoadUtil.getInstance().loadImage(item.getMedias().get(0).getPathname(), mAskImage, ImageLoadUtil.LoadOption.LOAD_SMALL);
        }

        setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.putExtra(Constant.IntentKey.ID, mFeedItem.getId());
                intent.setClass(mContext, DetailActivity.class);
                mContext.startActivity(intent);
            }
        });
    }


}
